#ifndef __OBJECT_POOL_H__
#define __OBJECT_POOL_H__

#include "object_pool_alloc.hpp"

namespace vpm 
{
	namespace utils
	{
		template <typename _Tp,typename _Alloc=ObjectPoolAllocator<_Tp> > 
		class ObjectPool
		{
		public:
			typedef size_t     size_type;
			typedef ptrdiff_t  difference_type;
			typedef _Tp*       pointer;
			typedef const _Tp* const_pointer;
			typedef _Tp&       reference;
			typedef const _Tp& const_reference;
			typedef _Tp        value_type;

			_Tp * malloc()
			{
				return new (m_allocator.allocate())_Tp();
			}

			template<typename P1>
			_Tp * malloc(P1 p1)
			{
				return new (m_allocator.allocate())_Tp(p1);
			}

			template<typename P1,typename P2>
			_Tp * malloc(P1 p1,P2 p2)
			{
				return new (m_allocator.allocate())_Tp(p1,p2);
			}

			template<typename P1,typename P2,typename P3>
			_Tp * malloc(P1 p1,P2 p2,P3 p3)
			{
				return new (m_allocator.allocate())_Tp(p1,p2,p3);
			}

			void free(_Tp * p)
			{
				m_allocator.deallocate(p);
			}

		private:
			_Alloc m_allocator;

		};
	}
}

#endif // 

